/**
 ******************************************************************************
 * @file    it.c
 * @author  MCD Application Team
 * @brief   Main Interrupt Service Routines.
 *          This file provides template for all exceptions handler and
 *          peripherals interrupt service routine.
 ******************************************************************************
 */

/* Includes ------------------------------------------------------------------*/
#include "bsp.h"
#include "bsp_cpu_it.h"
#include "netconf.h"
#include "os_obj.h"

/** @addtogroup
 * @{
 */
cpu_it_type cpu_it;

/**
 * @brief  This function handles USART0_IRQHandler exception.
 * @param  None
 * @retval None
 */
void USART1_IRQHandler(void)
{
	if (cpu_it.uart1)
		cpu_it.uart1();
}

/**
 * @brief  This function handles USART3_IRQHandler exception.
 * @param  None
 * @retval None
 */
void USART3_IRQHandler(void)
{
	if (cpu_it.uart3)
		cpu_it.uart3();
}

/**
 * @brief  This function handles UART7_IRQHandler exception.
 * @param  None
 * @retval None
 */
void UART7_IRQHandler(void)
{
	if (cpu_it.uart7)
		cpu_it.uart7();
}

/**
 * @brief  This function handles USART8_IRQHandler exception.
 * @param  None
 * @retval None
 */
void UART8_IRQHandler(void)
{
	if (cpu_it.uart8)
		cpu_it.uart8();
}

/**
 * @brief  this function handles emac handler.
 * @param  none
 * @retval none
 */
void EMAC_IRQHandler(void)
{
	/* handles all the received frames */
	while (emac_received_packet_size_get() != 0)
	{
		lwip_pkt_handle();
	}

	/* clear the emac dma rx it pending bits */
	emac_dma_flag_clear(EMAC_DMA_RI_FLAG);
	emac_dma_flag_clear(EMAC_DMA_NIS_FLAG);

	tx_semaphore_put(os_obj.sid_eth);
}
